<template>
    <div class="audit-apply-view">

      <div class="top-view">
        <el-form :inline="true" :model="datas" class="demo-form-inline" label-width="100px" size="medium" label-position="left">
          <el-form-item label="任务名称">
            <span>{{datas.task_name}}</span>
          </el-form-item>

          <el-form-item label="项目名称">
            <span>{{datas.project_name}}</span>
          </el-form-item>

          <el-form-item label="计划开始时间">
            <div v-if="olds.start_date != datas.start_date">
              <span>{{olds.start_date}}</span><span> -> </span><span>{{datas.start_date}}</span>
            </div>
            <div v-else><span>{{datas.start_date}}</span></div>
          </el-form-item>
          <el-form-item label="计划结束时间">
            <div v-if="olds.end_date != datas.end_date">
              <span>{{olds.end_date}}</span><span> -> </span><span>{{datas.end_date}}</span>
            </div>
            <div v-else><span>{{datas.end_date}}</span></div>
          </el-form-item>

          <el-form-item label="工期（天）">
            <div v-if="olds.duration != datas.duration">
              <span>{{olds.duration}}</span><span> -> </span><span>{{datas.duration}}</span>
            </div>
            <div v-else><span>{{datas.duration}}</span></div>
          </el-form-item>

          <el-form-item label="项目负责人">
            <div v-if="olds.person_in_charge && datas.person_in_charge">
              <div v-if="olds.person_in_charge.member_id != datas.person_in_charge.member_id">
                <span>{{olds.person_in_charge.member_name}}</span><span> -> </span><span>{{datas.person_in_charge.member_name}}</span>
              </div>
              <div v-else><span v-if="datas.person_in_charge">{{datas.person_in_charge.member_name}}</span></div>
            </div>
            <div v-else><span v-if="datas.person_in_charge">{{datas.person_in_charge.member_name}}</span></div>

          </el-form-item>

          <el-form-item label="项目参与人">

            <div class="task-member">
              <div class="left">
                <template v-if="member1">
                  <div v-for="item in member1">{{item.member_name}}</div>
                </template>
              </div>
              <span> -> </span>
              <div class="right">
                <template v-if="member2">
                  <div v-for="item in member2">{{item.member_name}}</div>
                </template>
              </div>
            </div>

          </el-form-item>

        </el-form>
      </div>

      <el-form :model="datas" class="demo-form-inline" label-width="100px" size="medium" label-position="left">

        <el-form-item label="变更原因">
          <span>{{datas.change_cause}}</span>
        </el-form-item>

        <el-form-item label="变更影响程度">
          <span>{{datas.change_level}}</span>
        </el-form-item>


        <el-form-item label="详细描述" prop="work_content">
          <span>{{datas.details_describe}}</span>
        </el-form-item>

        <el-form-item label="变更影响描述">
          <span>{{datas.change_describe}}</span>
        </el-form-item>


      </el-form>

      <el-form :model="datas" class="demo-form-inline" label-width="200px" size="medium" label-position="left">

        <el-form-item label="自动更新后置任务时间安排">
          <span>{{datas.is_update_task_time ? '是' : '否'}}</span>
        </el-form-item>

      </el-form>

      <el-form :model="datas" class="demo-form-inline" label-width="100px" size="medium" label-position="left" v-if="datas.change_status == 1">

        <el-form-item label="审批结论">
          <el-select v-model="datas.approval_result">
            <el-option
              v-for="item in result"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="审批意见">
          <el-input v-model="datas.approval_opinion" ></el-input>
        </el-form-item>

      </el-form>


    </div>
</template>

<script>
    export default {
        name: "auditApplyView",
        data:function () {
            return{
                datas:{},
                olds:{},
                memberChange:false,

                member1:[
                    {
                        member_id:1,
                        member_name:'111'
                    },
                    {
                        member_id:1,
                        member_name:'222'
                    },
                ],
                member2:[
                    {
                        member_id:1,
                        member_name:'555'
                    },
                    {
                        member_id:1,
                        member_name:'666'
                    },
                    {
                        member_id:1,
                        member_name:'777'
                    },
                ],
                result:[
                    {
                        value:1,
                        label:'同意'
                    },
                    {
                        value:2,
                        label:'拒绝'
                    }
                ]
            }
        },
        methods:{
            setData:function (data) {
                this.datas = data;
                this.datas.approval_result = 1;
                this.datas.approval_opinion = "";
                console.log(this.datas);
                if (data.data){
                    this.olds = JSON.parse(data.data);

                    let str = (this.olds.task_member && this.olds.task_member.length > 0) ? JSON.stringify(this.olds.task_member) : ""
                    let str1 = (this.datas.task_member && this.datas.task_member.length > 0) ? JSON.stringify(this.datas.task_member) : ""
                    this.memberChange = str != str1
                }
            }
        }
    }
</script>

<style lang="scss">
  @import "@/assets/scss/views/projectManagement/applyList/auditApplyView.scss";
</style>
